<template>
  <el-dialog v-model="dialogVisible" title="增加产品" width="500px" @close="dialogVisible = false">
    <el-form ref="formPassRef" :rules="formRules" :model="formPass" label-width="120px">
      <el-form-item label="能源" required prop="projectId">
        <el-select v-model="formPass.projectId" placeholder="请选择主体">
          <el-option v-for="(op, oIndex) in ['周口市中医院']"  :key="op" :label="op" :value="op" />
        </el-select>
      </el-form-item>
      <el-form-item label="产品名称" prop="name"  required>
        <el-select v-model="formPass.projectId" placeholder="请选择主体">
        <el-option v-for="(op, oIndex) in ['周口市中医院']"  :key="op" :label="op" :value="op" />
        </el-select>
      </el-form-item>
      <el-form-item label="换算因子" prop="describe" required>
        <el-input v-model="formPass.describe" type="text" autocomplete="off" placeholder="请输入产品描述" />
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="dialogVisible = false">取消</el-button>
        <el-button type="primary" class="save" @click="changeSubmitFn(formPassRef)"> 确 定 </el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup lang="ts">
  import { reactive , getCurrentInstance ,defineExpose , nextTick,ref } from 'vue';
  type FormInstance = InstanceType<typeof ElForm>;
  let dialogVisible = ref(false)
  const formRules = {
    audit_comment: [
      {
        'required': true,
        'message': `请输入驳回意见`,
        'trigger': `blur`
      }, {
        'max': 140,
        'message': `长度不能超过140字`,
        'trigger': `blur`
      }
    ]
  }
  const formPassRef = ref();
  let formPass = reactive({
    'newtext': ``,
    'confirmtext': ``
  });

  const changeSubmitFn = (formEl: FormInstance | undefined) => {
    if (!formEl) return;
    formEl.validate(async valid => {
      if (valid) {

      }
    });
    dialogVisible.value = false
  }
  // 初始化方法
  const open =  (key , row) => {
    dialogVisible.value = true

  };

  defineExpose({open})
</script>